package com.ruoyi.adapaySettleaccount.controller;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.adapaySettleaccount.domain.AdapaySettleaccount;
import com.ruoyi.adapaySettleaccount.service.IAdapaySettleaccountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 汇付结算账户Controller
 *
 * @author ch
 * @date 2022-02-22
 */
@RestController
@RequestMapping("/adapaySettleaccount/adapaySettleaccount")
public class AdapaySettleaccountController extends BaseController
{
    @Autowired
    private IAdapaySettleaccountService adapaySettleaccountService;

    /**
     * 查询汇付结算账户列表
     */
    @PreAuthorize("@ss.hasPermi('adapaySettleaccount:adapaySettleaccount:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdapaySettleaccount adapaySettleaccount)
    {
        startPage();
        List<AdapaySettleaccount> list = adapaySettleaccountService.selectAdapaySettleaccountList(adapaySettleaccount);
        return getDataTable(list);
    }

    /**
     * 导出汇付结算账户列表
     */
    @PreAuthorize("@ss.hasPermi('adapaySettleaccount:adapaySettleaccount:export')")
    @Log(title = "汇付结算账户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AdapaySettleaccount adapaySettleaccount)
    {
        List<AdapaySettleaccount> list = adapaySettleaccountService.selectAdapaySettleaccountList(adapaySettleaccount);
        ExcelUtil<AdapaySettleaccount> util = new ExcelUtil<AdapaySettleaccount>(AdapaySettleaccount.class);
        return util.exportExcel(list, "汇付结算账户数据");
    }

    /**
     * 获取汇付结算账户详细信息
     */
    @PreAuthorize("@ss.hasPermi('adapaySettleaccount:adapaySettleaccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(adapaySettleaccountService.selectAdapaySettleaccountById(id));
    }

    /**
     * 新增汇付结算账户
     */
    @PreAuthorize("@ss.hasPermi('adapaySettleaccount:adapaySettleaccount:add')")
    @Log(title = "汇付结算账户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdapaySettleaccount adapaySettleaccount)
    {
        return toAjax(adapaySettleaccountService.insertAdapaySettleaccount(adapaySettleaccount));
    }

    /**
     * 修改汇付结算账户
     */
    @PreAuthorize("@ss.hasPermi('adapaySettleaccount:adapaySettleaccount:edit')")
    @Log(title = "汇付结算账户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdapaySettleaccount adapaySettleaccount)
    {
        adapaySettleaccount.setUpdateType(DicConstants.BUSINESS_Manager.getCode());
        return toAjax(adapaySettleaccountService.updateAdapaySettleaccount(adapaySettleaccount));
    }

    /**
     * 删除汇付结算账户
     */
    @PreAuthorize("@ss.hasPermi('adapaySettleaccount:adapaySettleaccount:remove')")
    @Log(title = "汇付结算账户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adapaySettleaccountService.logicDeleteAdapaySettleaccount(ids,DicConstants.BUSINESS_Manager.getCode(),SecurityUtils.getUserId()));
    }
}
